﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KPIS.GERP.GBMS.IBLL;
using KPIS.GERP.GBMS.MODEL;
using KPIS.GERP.GBMS.DAL;
using KPIS.GERP.GBMS.DAL;
using KPIS.GERP.GBMS.DALFactory;

namespace KPIS.GERP.GBMS.BLL
{
    public sealed class ProjectRequestKPIBLL : IProjectKPIBLL
    {
        private static readonly IProjectRequestKPIDAL dal = DataAccess.CreateProjectKPI();
        private IProjectRequestKPIDAL prjDAL =  new ProjectRequestKPIDAL();

        public void Insert(string code, string name, string descr, string monthstart, string monthend, string reason, string objects, string target, string plan, string detail, string remark, string strategy, string jobsite, string year)
        {
            //ProjectInfo pjInfo = new ProjectInfo(0, code, name, descr, DateTime.Today, monthstart, monthend, reason, objects, target, plan, detail, remark, strategy, jobsite, Convert.ToInt32(year), "", new UserRecordInfo(1, null));

            //if (dal.Insert(pjInfo) > 0)
            //{

            //}
            //else
            //{

            //}
        }

        public void Update(string seq, string code, string name, string descr, string monthstart, string monthend, string reason, string objects, string target, string plan, string detail, string remark, string strategy, string jobsite, string year)
        {
            //ProjectInfo pjInfo = new ProjectInfo(Convert.ToInt32(seq), code, name, descr, DateTime.Today, monthstart, monthend, reason, objects, target, plan, detail, remark, strategy, jobsite, Convert.ToInt32(year), "", new UserRecordInfo(null, 1));

            //if (dal.Update(pjInfo) > 0)
            //{

            //}
            //else
            //{

            //}
        }

        public void Delete(string seq)
        {
            //if (dal.Delete(Convert.ToInt32(seq)) > 0)
            //{

            //}
            //else
            //{

            //}
        }

        public IList<ProjectKPIInfo> Search(string seq, string pjseq)
        {
            ProjectKPIInfo info = new ProjectKPIInfo();

            int inSeq = (seq.Length > 0) ? Convert.ToInt32(seq) : 0;
            int inProjectSeq = (pjseq.Length > 0) ? Convert.ToInt32(pjseq) : 0;

            ProjectInfo pj = new ProjectInfo();
            pj.Sequence = inProjectSeq;

            info.Sequence = inSeq;
            info.Project = pj;

            return prjDAL.Search(info);
        }
    }
}
